﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.UI.HtmlControls;
using CompanyBussiness;

namespace Website.customer.Control
{
    public partial class cListNewsRandom : System.Web.UI.UserControl
    {
        HtmlMeta metaTag;
        NewsManagement newsMana = new NewsManagement();
        LanguagesManagement languageMana = new LanguagesManagement();
        TurnOverService overServices = new TurnOverService();
        CompanyBussiness.New news = new New();
        CompanyBussiness.Language language;
        Metadata meta;
        public int CurPage = 1;
        int TotalRow;
        int TotalPage;
        int StartRow = 0;
        int categoryIDs;
        string modulCode;

        protected void Page_Load(object sender, EventArgs e)
        {
            modulCode = Request.QueryString["Mod"];
            //loadModul();
            if (Request[CONST.QUERYSTRING_CATEGORY] != null)
                categoryIDs = int.Parse(Request[CONST.QUERYSTRING_CATEGORY].ToString());

            if (Request.Cookies[CONST.COOKIES_LANGUAGE] == null)
            {
                Session[CONST.SESSION_LANGUAGE] = "";
                language = languageMana.GetLanguageByCode("vi-VN");
            }
            else
            {
                Session[CONST.SESSION_LANGUAGE] = Request.Cookies[CONST.COOKIES_LANGUAGE][CONST.COOKIES_LANGUAGE_ID];
                language = languageMana.GetLanguageByID(int.Parse(Session[CONST.SESSION_LANGUAGE].ToString()));
            }
            if (!Page.IsPostBack)
            {
                if (modulCode == "MNEWS")
                    LoadDataList();
            }
        }


        protected void LoadDataList()
        {
            try
            {
                dataListNewsRandom.DataSource = newsMana.GetListNewsRandom(categoryIDs, true);
                dataListNewsRandom.DataBind();

                if (dataListNewsRandom.Items.Count == 0)
                { 
                    
                }
            }
            catch (Exception)
            { 
            }
        }


    }
}